package com.smxy.mall.common;

import com.smxy.mall.entity.User;
import com.smxy.mall.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
public class Task {
    @Autowired
    private UserService userService;

//    @Scheduled(fixedRate = 3000)
//    public void addUserTask() {
//        User user = new User();
//        user.setName("定时任务");
//        user.setPhone("定时任务phone");
//        userService.save(user);
//    }

    @Scheduled(cron = "0 11 9 * * MON-FRI")
    public void addUserTask() {
        User user = new User();
        user.setName("定时任务");
        user.setPhone("定时任务phone");
        userService.save(user);
    }
}
